#region Referencias
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Collections.Generic;
using System.Collections;
#endregion

/// <summary>
/// Summary description for DataInputStream
/// </summary>
namespace J2ME.RMS
{
    public class DataInputStream
    {
        private byte[] arrInt;
        public int cantidadLeida = -1;
  
        public byte[]  readBytes( )
        {
            byte[] arreglo = new byte[arrInt.Length - cantidadLeida - 1];

            for (int i = 0; i < arreglo.Length; i++)
            {
                arreglo[i] = arrInt[++cantidadLeida];
            }
            return arreglo;
        }

        public DataInputStream(byte[] lista)
        {
            arrInt = lista;
        }

        public int readInt()
        {

            byte ch1 = arrInt[++cantidadLeida];
            byte ch2 = arrInt[++cantidadLeida];
            byte ch3 = arrInt[++cantidadLeida];
            byte ch4 = arrInt[++cantidadLeida];

            return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
        }

        public char readChar()
        {

            byte ch1 = arrInt[++cantidadLeida];
            byte ch2 = arrInt[++cantidadLeida];

            return (char)((ch1 << 8) + (ch2 << 0));

        }

        public short readShort()
        {

            byte ch1 = arrInt[++cantidadLeida];
            byte ch2 = arrInt[++cantidadLeida];

            return (short)((ch1 << 8) + (ch2 << 0));
        }

        public string readString()
        {

            int strLen = readInt();

            char[] str = new char[strLen];
            for (int it = 0; it < strLen; it++)
            {
                str[it] = readChar();
            }

            return new String(str);

        }

        public long readLong()
        {
            return ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL);
        }


    }
}
